const mgModel = require("../model/managerModel.js");

module.exports.getMgBypage = (req,res) =>{
	console.log(req.headers.authorization)
	mgModel.getMgBypage().then( result =>{
		if(result.length == 0){
			res.send({
			meta: {
				  msg: "获取用户列表成功",
				  status: 402
				}
			})
		}else{
			let managers = [];
			for(i in result){
				let manage = result[i];
				managers.push({
					mg_id: manage.mg_id,
					mg_name: manage.mg_name,
					mg_pwd: manage.mg_pwd,
					mg_time: manage.mg_time,
					role_id: manage.role_id,
					mg_mobile: manage.mg_mobile,
					mg_email: manage.mg_email,
					mg_state: manage.mg_state
				})
			}
			res.send({
				data: managers,
				meta: {
					msg: '获得用户列表失败',
					status: 200
				}
			})
		}
	}).catch( error =>{
		res.send({
			msg: '获得用户列表失败',
			status: 500
		})
	})
}